/**
 * 
 */
package com.monte.export;

import java.io.IOException;
import java.io.OutputStream;


/**
 * 单列表导出
 * @author fengmengyue
 *
 */
public abstract class SimpleExportor<T> implements Exportor<T> {
	
	/**
	 * 数据源
	 */
	protected ExportDataSource<T> dataSource;
	
	/**
	 * 输出流
	 */
	protected OutputStream outputStream;
	
	/**
	 * 导出配置
	 */
	protected Configure configure;
	
	public SimpleExportor(ExportDataSource<T> dataSource,OutputStream outputStream,Configure configure){
		this.dataSource = dataSource;
		this.outputStream = outputStream;
		this.configure = configure;
	}

	protected DataPage<T> getDataPage(DataPage<T> dataPage){
		if(dataPage == null){
			return null;
		}
		return dataSource.getData(dataPage);
	}
	
	@Override
	public void export() throws IOException {
		startExport();
	}
	
	protected abstract void startExport() throws IOException;
}
